<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">

    <ui:define name="content">
        <h:form id="list">  

            <p:dataTable var="setMealList" value="#{mealManagerBean.setMealList}" paginator="true" rows="15"  
                         selection="#{mealManagerBean.selectedSetMeal}" selectionMode="single"  
                         onRowSelectUpdate="formMain formPrice formAvail formPriceControl" rowSelectListener="#{mealManagerBean.selectProduct}"
                         emptyMessage ="No set meal found." style="width:200px">  

                <f:facet name="header">  
                    List of Set Meals  
                </f:facet>  

                <p:column sortBy="#{setMealList.name}" filterBy="#{setMealList.name}">  
                    <f:facet name="header">  
                        <h:outputText value="Set Meal Name" />  
                    </f:facet>  
                    <h:outputText value="#{setMealList.name}" />  
                </p:column>  
            </p:dataTable> 
        </h:form> 
    </ui:define>
    <ui:define name="contentMeal"> 

        <h:form id="formMain" style="position: relative; float:left; width: 600px;">
            <f:metadata>
                <f:viewParam name ="visibility" value ="#{mealManagerBean.selectedSetMeal.visibility}" />
            </f:metadata>

            <h:panelGrid  >
                <h:outputLabel for="setMealName" style="font-weight: bold" value="Set Meal Name: " />
                <h:inputText id="setMealName" value="#{mealManagerBean.selectedSetMeal.name}">
                </h:inputText>
                <p:message for="setMealName" />


                <h:outputLabel for="originalPrice" style="font-weight: bold" value="Original Price: " />
                <h:inputText id="originalPrice" value="#{mealManagerBean.selectedSetMeal.originalPrice}">
                </h:inputText>
                <p:message for="originalPrice" />

                <h:outputLabel for="description" style="font-weight: bold" value="Description: " />
                <p:inputTextarea id="description" value="#{mealManagerBean.selectedSetMeal.description}"   style="width:300px; height: 100px">
                </p:inputTextarea>
                <p:message for="description" />

                <h:outputLabel style="font-weight: bold" value="Visible to Customers: " />                 
                <p:button value="Enable" disabled="#{mealManagerBean.selectedSetMeal.visibility}" outcome="StakeholderUpdateSelectedSetMeal">
                    <f:param name="visibility" value="true" />
                </p:button>
                <p:button value="Disable" disabled="#{!mealManagerBean.selectedSetMeal.visibility}" outcome="StakeholderUpdateSelectedSetMeal">
                    <f:param name="visibility" value="false" />
                </p:button>


                <h:outputLabel for="image" style="font-weight: bold" value="Set Meal Image: " />
                <h:graphicImage id="gi" alt="The image could not be found."   value="/images/#{mealManagerBean.selectedSetMeal.imageLink}" width="670" height="450"></h:graphicImage>

                <p:fileUpload id="upload" fileUploadListener="#{mealManagerBean.handleImageUploadSetMeal}" 
                              allowTypes="*.jpg;*.png;*.gif;" description="Images" update ="growl gi"/>     

                <p:dataTable var="mealList" value="#{mealManagerBean.mealOfBranch}" selection="#{mealManagerBean.selectedMeals_update}" paginator="true" rows="10">
                    <p:column selectionMode="multiple" />
                    <p:column sortBy="#{mealList.type.name}" filterBy="#{mealList.type.name}">  
                        <f:facet name="header">  
                            <h:outputText value="Type" />  
                        </f:facet>  
                        <h:outputText value="#{mealList.type.name}" />  
                    </p:column> 
                    <p:column sortBy="#{mealList.name}" filterBy="#{mealList.name}">  
                        <f:facet name="header">  
                            <h:outputText value="Meal Name" />  
                        </f:facet>  
                        <h:outputText value="#{mealList.name}" />  
                    </p:column>  

                    <p:column sortBy="#{mealList.description}" filterBy="#{mealList.description}">  
                        <f:facet name="header">  
                            <h:outputText value="Description" />  
                        </f:facet>  
                        <h:outputText value="#{mealList.description}" />  
                    </p:column>  

                </p:dataTable>

            </h:panelGrid>
            <br/>
            <p:commandButton id="btn1" value="Save Set Meal Update" update="accordion growl" actionListener="#{mealManagerBean.updateSetMeal}" ajax="true" />
            <p:commandButton id="btn2" value="Delete Set Meal" update="accordion list growl" actionListener="#{mealManagerBean.deleteSetMeal}" ajax="true" />
        </h:form>
</ui:composition>